package artifact

import (
	"ys.calc/pointFunction"
	"ys.calc/role"
)

type StatWords struct {
	wordValue float64
	BonusFunc func(r *role.Role)
}

func getNormalFlower() StatWords {
	return StatWords{
		wordValue: 4870,
		BonusFunc: func(r *role.Role) {
			pointFunction.FlatHP(4870, r)
		},
	}
}
func getNormalPlume() StatWords {
	return StatWords{
		wordValue: 311,
		BonusFunc: func(r *role.Role) {
			pointFunction.FlatAtk(311, r)
		},
	}
}

func getNormalEon(au bool, hu bool, du bool, mu bool, ru bool) []StatWords {
	eonSign := func(role2 *role.Role, v string) { role2.Eon = v }
	others := getNormalOthers(au, hu, du, mu, eonSign)
	if ru {
		return append(others, getMainRecharge(eonSign))
	} else {
		return others
	}
}
func getNormalGoblet(au bool, hu bool, du bool, mu bool) []StatWords {
	gobletSign := func(role2 *role.Role, v string) { role2.Goblet = v }
	others := getNormalOthers(au, hu, du, mu, gobletSign)
	return append(others, getMainIncrease(gobletSign))
}
func getNormalCirclet(au bool, hu bool, du bool, mu bool) []StatWords {
	circletSign := func(role2 *role.Role, v string) { role2.Circlet = v }
	others := getNormalOthers(au, hu, du, mu, circletSign)
	return append(others, getMainCritRate(circletSign), getMainCritDmg(circletSign))
}
func getNormalOthers(au bool, hu bool, du bool, mu bool, f func(rp *role.Role, v string)) []StatWords {
	atk := getMainAtk(f)
	defense := getMainDefense(f)
	hp := getMainHp(f)
	mastery := getMainElementalMastery(f)
	var words []StatWords
	if au {
		words = append(words, atk)
	}
	if hu {
		words = append(words, hp)
	}
	if du {
		words = append(words, defense)
	}
	if mu {
		words = append(words, mastery)
	}
	return words
}

func getMainAtk(f func(rp *role.Role, v string)) StatWords {
	return StatWords{
		wordValue: 46.6,
		BonusFunc: func(r *role.Role) {
			f(r, "攻")
			pointFunction.PercentATK(46.6, r)
		},
	}
}

func getMainDefense(f func(rp *role.Role, v string)) StatWords {
	return StatWords{
		wordValue: 58.3,
		BonusFunc: func(r *role.Role) {
			f(r, "防")
			pointFunction.PercentDefense(58.3, r)
		},
	}
}

func getMainHp(f func(rp *role.Role, v string)) StatWords {
	return StatWords{
		wordValue: 46.6,
		BonusFunc: func(r *role.Role) {
			f(r, "生")
			pointFunction.PercentHP(46.6, r)
		},
	}
}
func getMainRecharge(f func(rp *role.Role, v string)) StatWords {
	return StatWords{
		wordValue: 51.8,
		BonusFunc: func(r *role.Role) {
			f(r, "充")
			pointFunction.AddRecharge(51.8, r)
		},
	}
}

func getMainIncrease(f func(rp *role.Role, v string)) StatWords {
	return StatWords{
		wordValue: 46.6,
		BonusFunc: func(r *role.Role) {
			f(r, "属")
			pointFunction.AddIncrease(46.6, r)
		},
	}
}

//func getMainPhysicalDamage(f func(rp *role.Role, v int)) StatWords {
//	return StatWords{
//		wordValue: 46.6,
//		BonusFunc: func(r *role.Role) {
//			f(r, 8)
//			pointFunction.AddIncrease(58.3, r)
//		},
//	}
//}

func getMainElementalMastery(f func(rp *role.Role, v string)) StatWords {
	return StatWords{
		wordValue: 20,
		BonusFunc: func(r *role.Role) {
			f(r, "精")
			pointFunction.AddElementalMastery(20, r)
		},
	}
}

func getMainCritRate(f func(rp *role.Role, v string)) StatWords {
	return StatWords{
		wordValue: 31.1,
		BonusFunc: func(r *role.Role) {
			f(r, "暴")
			pointFunction.AddCritRate(31.1, r)
		},
	}
}

func getMainCritDmg(f func(rp *role.Role, v string)) StatWords {
	return StatWords{
		wordValue: 62.2,
		BonusFunc: func(r *role.Role) {
			f(r, "爆")
			pointFunction.AddCritDmg(62.2, r)
		},
	}
}
